<template>
	<view>
		<Lines></Lines>
		<view class='login-tel'>
			<view class='tel-main'>
				<view class='login-from'>
					<view class='login-user'>
						<text>手机号</text>
						<input type="number" focus="true" v-model="userTel" value="" placeholder="请输入手机号" />
						<!-- <input type="text" v-model="userName" value="" placeholder="请输入手机号" /> -->
					</view>
				</view>
				<view class="tel" @tap="goNextCode">下一步</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		queryUsersByPrarm
	} from '../../api/user.js'
	import Lines from "@/pages/common/components/lines.vue"
	import HttpRequest from '@/utils/request.js'
	export default {
		data() {
			return {
				userTel: "",
				rules: {
					userTel: {
						rule: /^1[3456789]\d{9}$/,
						msg: "请输入11位手机号"
					}
				}
			}
		},
		components: {
			Lines
		},
		methods: {
			goNextCode() {
				if (!this.validate("userTel")) return;
				queryUsersByPrarm({
					mobile: this.userTel
				}).then(res => { 
					
					// if (res.data.data.length >= 1) {
					// 	uni.showToast({
					// 		title: '已注册',
					// 		icon: "none"
					// 	})
					// }
					// else{
						uni.navigateTo({
							url:"../login-code/login-code?phone="+this.userTel+""
						})
					// }

				})


			}, // 验证
			validate(key) {
				let bool = true;
				if (!this.rules[key].rule.test(this[key])) {
					uni.showToast({
						title: this.rules[key].msg,
						icon: "none"
					})
					bool = false;
					return false;
				}
				return bool;
			},
		}
	}
</script>

<style scoped>
	.login-tel {
		width: 100vw;
		height: 100vh;
	}

	.tel-main {
		padding: 0 20rpx;
	}

	.login-from {
		padding: 30rpx 0;
	}

	.login-user {
		font-size: 32rpx;
		padding: 10rpx 0;
		display: flex;
		align-items: center;
		border-bottom: 2rpx solid #f7f7f7;
	}

	.login-user text {
		font-size: 28rpx;
		display: inline-block;
		line-height: 32rpx;
		margin-right: 20rpx;
	}

	.user-text {
		padding-right: 10rpx;
	}

	.tel {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color: #FFFFFF;
		font-size: 17rpx;
		background-color: #49BDFB;
		border-radius: 40rpx;
	}
</style>
